package io.bdmc.modules.bss.service.impl;

import java.util.List;

import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;
import io.bdmc.common.utils.MyPage;
import io.bdmc.modules.bss.entity.DeviceMachineDisk;
import io.bdmc.modules.bss.mapper.DeviceMachineDiskMapper;
import io.bdmc.modules.bss.service.IDeviceMachineDiskService;

/**
 * <p>
 * 单盘数据表 服务实现类
 * </p>
 *
 * @author 黄露
 * @since 2021-04-28
 */
@Service
public class DeviceMachineDiskServiceImpl extends ServiceImpl<DeviceMachineDiskMapper, DeviceMachineDisk>
        implements IDeviceMachineDiskService {
    @Autowired
    DeviceMachineDiskMapper _devicemachinediskMapper;

    @Override
    public MyPage<DeviceMachineDisk> mySelectPage(MyPage<DeviceMachineDisk> myPage) {
        return _devicemachinediskMapper.mySelectPage(myPage);
    }

    @Transactional
    @Override
    public Boolean deleteAndInsert(List<DeviceMachineDisk> deviceMachineDiskList) {
        int rackId = deviceMachineDiskList.get(0).getMachineRackId();
        remove(new QueryWrapper<DeviceMachineDisk>().eq("machine_rack_id", rackId));
        saveBatch(deviceMachineDiskList);
        return null;
    }

}